home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / SWAG9605.DDD / 0087_Re: Delphi DDE Link with WP Win 6.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-05-31  |  1.7 KB  |  47 lines

  1. {
  2. >: : DDE must be used for my task as WPWIN6 does not support OLE automation.
  3. >
  4. >
  5. >        How can I call the Word Processor to print a DOC or mail merge?
  6. >
  7. >Dennis
  8.  
  9. Below is some sample code starting WPerfect and establishing a DDE link with it.
  10. For talking to WinWord I use an OLE link. WordPerfect 6.x does not support OLE automation, hence
  11. the need to revert to a DDE link to control Word Perfect.
  12. }
  13.  
  14. procedure TFormCases.CreateWordPerfect(MyDocName : String13; Path : String );
  15. var tme : TModuleEntry; h : Word; B : Boolean;
  16. begin
  17.  with DDEClientConv1 do  begin
  18.   ServiceApplication := GWPPath; { Word Perfect path location as a string }
  19.    tme.dwSize := sizeof(TModuleEntry);
  20.    h := ModuleFindName(@tme,'WPWIN60');
  21.    if (h<=0) then begin
  22.     SayActivity('',txtWLIS,txtStartWP,''); {splash message screen }
  23.     SetLink('WPWIN60_Macros', 'Commands');
  24.     B:=OpenLink;
  25.     HideActivity; { hide slplash message}
  26.    end; { h <=0 }
  27.    B:= SetLink('WPWIN60_Macros', 'Commands');
  28.    B:=OpenLink;
  29.    if  not B then ShowMessage('WordPerfect DDE Link failed');
  30.  
  31.    StrPCopy(@Cstr,'Type("Normally WinLaw would create '+Path+' at this point.")');
  32.    B:= ExecuteMacro(@CStr,False);
  33.    StrPCopy(@Cstr,'HardReturn()');
  34.    ExecuteMacro(@CStr,False);
  35.    StrPCopy(@Cstr,'Type("For now it demonstates controlling Word Perfect.")');
  36.    B:= ExecuteMacro(@CStr,False);
  37.    StrPCopy(@Cstr,'HardReturn()');
  38.    B:= ExecuteMacro(@CStr,False);
  39.    StrPCopy(@Cstr,'HardReturn()');
  40.    ExecuteMacro(@CStr,False);
  41.    StrPCopy(@Cstr,'AppActivate("WordPerfect")');
  42.    B:= ExecuteMacro(@Cstr,False);
  43.    {if (not B) then ShowMessage('Activation WP failed');}
  44.    CloseLink;
  45.   end;
  46. end;
  47.